package com.mlog.njyjy.ndop.share.sql.support;

import com.mlog.njyjy.ndop.share.sql.annotation.Column;

/**
 * 数据库列
 * @author alex
 * @version v1.0 2020/7/8
 */
public class SqlTableColumn {

    /**
     * 列名 默认是下划线类型(model中是驼峰)
     */
    private String field;

    /**
     * 类型 sql type (包含长度/精度 等)
     * eg `varchar(32)` `bigint(20)`
     */
    private String sqlType;

    /**
     * 是否可为null
     */
    private boolean nullable = true;

    /**
     * 是否为列建立唯一性约束
     */
    private boolean unique = false;

    /**
     * 是否是主键
     */
    private boolean pk;

    /**
     * 默认值
     */
    private Object defaultValue;

    /**
     * 其他参数
     * eg `auto_increment`
     */
    private String extra;

    /**
     * 列注解
     */
    private Column columnAnnotation;

    public String getField() {
        return field;
    }

    public SqlTableColumn setField(String field) {
        this.field = field;
        return this;
    }

    public String getSqlType() {
        return sqlType;
    }

    public SqlTableColumn setSqlType(String sqlType) {
        this.sqlType = sqlType;
        return this;
    }

    public boolean isNullable() {
        return nullable;
    }

    public SqlTableColumn setNullable(boolean nullable) {
        this.nullable = nullable;
        return this;
    }

    public boolean isPk() {
        return pk;
    }

    public SqlTableColumn setPk(boolean pk) {
        this.pk = pk;
        return this;
    }

    public Column getColumnAnnotation() {
        return columnAnnotation;
    }

    public SqlTableColumn setColumnAnnotation(Column columnAnnotation) {
        this.columnAnnotation = columnAnnotation;
        return this;
    }

    public Object getDefaultValue() {
        return defaultValue;
    }

    public SqlTableColumn setDefaultValue(Object defaultValue) {
        this.defaultValue = defaultValue;
        return this;
    }

    public String getExtra() {
        return extra;
    }

    public SqlTableColumn setExtra(String extra) {
        this.extra = extra;
        return this;
    }

    public boolean isUnique() {
        return unique;
    }

    public SqlTableColumn setUnique(boolean unique) {
        this.unique = unique;
        return this;
    }
}
